import * as turf from "@turf/helpers";
import { nearestPointOnLine } from "@turf/nearest-point-on-line";
import { lineSplit } from "@turf/line-split";
export function getNearestPointOnLine(point, lines) {
  const line = turf.lineString(lines);
  const pt = turf.point(point);
  const snapped = nearestPointOnLine(line, pt, { units: "kilometers" });
  return snapped;
}

export function splitLineByPoint(lines, point) {
  const line = turf.lineString(lines);
  const pt = turf.point(point);
  const split = lineSplit(line, pt);
  return split;
}
